package com.server.llh.llhserverwork.activity.my;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.family.llh.lelaohuitoastview.dialog.toast.T;
import com.lelaohui.net.netmanager.INetRequestManager;
import com.lelaohui.net.netmanager.NetRequestManager;
import com.llh.llhsuppliers.R;
import com.server.llh.llhserverwork.activity.base.LlhBaseActivity;
import com.server.llh.llhserverwork.activity.food.FoodOrderAllFragment;
import com.server.llh.llhserverwork.activity.food.SFoodOrderInfoActivity;
import com.server.llh.llhserverwork.activity.query.QueryAccoutInfoActivity;
import com.server.llh.llhserverwork.activity.query.QueryMyTaskActivity;
import com.server.llh.llhserverwork.activity.work.MySerTaskActivity;
import com.server.llh.llhserverwork.adapter.MyMenuAdapter;
import com.server.llh.llhserverwork.app.LelaohuirelativesApp;
import com.server.llh.llhserverwork.bean.Constants;
import com.server.llh.llhserverwork.utils.SharedPreferenceUtil;
import com.server.llh.llhserverwork.view.AlertDialog;
import com.server.llh.llhserverwork.view.MyGridView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ZTF on 2017-06-05.
 * 我的
 */

public class MyActivity extends LlhBaseActivity {
    @BindView(R.id.titleName)
    TextView titleName;
    @BindView(R.id.main_back)
    ImageButton mainBack;
    @BindView(R.id.leftBtn_RL_title_base)
    RelativeLayout leftBtnRLTitleBase;
    @BindView(R.id.serverName)
    TextView serverName;
    @BindView(R.id.linearLayout1)
    LinearLayout linearLayout1;
    @BindView(R.id.my_phone)
    ImageView myPhone;
    @BindView(R.id.userNameTxt)
    TextView userNameTxt;
    @BindView(R.id.integralTxt)
    TextView integralTxt;
    @BindView(R.id.server_menu)
    MyGridView serverMenu;
    @BindView(R.id.my_signin)
    TextView mySignin;
    @BindView(R.id.order_all)
    TextView orderAll;
    @BindView(R.id.my_money)
    TextView myMoney;
    @BindView(R.id.my_subscribe)
    TextView mySubscribe;
    @BindView(R.id.my_eva)
    TextView myEva;
    @BindView(R.id.my_client)
    TextView myClient;
    @BindView(R.id.my_msg)
    TextView myMsg;
    @BindView(R.id.updatePwd)
    TextView updatePwd;
    @BindView(R.id.updateAddress)
    TextView updateAddress;
    @BindView(R.id.server_ev)
    TextView serverEv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        mainBack.setVisibility(View.INVISIBLE);
        String userNameStr= SharedPreferenceUtil.getUserInfo(Constants.UserInfo.USER_NAMW,getApplicationContext());
        String userPhoneStr= SharedPreferenceUtil.getUserInfo(Constants.UserInfo.TELE_PHONE,getApplicationContext());
        integralTxt.setText(userPhoneStr);
        userNameTxt.setText(userNameStr);
        titleName.setText("我的");
        serverMenu.setAdapter(new MyMenuAdapter(getApplicationContext()));
        serverMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent=null;
                switch (position){
                    case 0:
                        intent=new Intent(getApplicationContext(),QueryAccoutInfoActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
//                        intent=new Intent(getApplicationContext(),SFoodOrderInfoActivity.class);
//                        intent=new Intent(getApplicationContext(),FoodOrderAllFragment.class);
                        break;
                    case 2:
//                        intent=new Intent(getApplicationContext(),SignInActivity.class);
                        break;
                    case 3:
                        intent=new Intent(getApplicationContext(),UpdatePwdActivity.class);
                        startActivity(intent);
                        break;
                    case 4:
//                        showInfo();
                        intent=new Intent(getApplicationContext(),SearchNfcActivity.class);
                        startActivity(intent);
                        break;
                    case 5:
                        showInfo();
//                        intent=new Intent(getApplicationContext(),SignInActivity.class);
                        break;
                    case 6:
//                        intent=new Intent(getApplicationContext(),SignInActivity.class);
                        break;
                    case 7:
//                        intent=new Intent(getApplicationContext(),SignInActivity.class);
                        break;

                    case 8:
//                        intent=new Intent(getApplicationContext(),UpdatePwdActivity.class);
                        break;
                    case 9:
//                        intent=new Intent(getApplicationContext(),SignInActivity.class);
                        break;
                    case 10:
//                        intent=new Intent(getApplicationContext(),SignInActivity.class);
                        break;
                    case 11:
//                        intent=new Intent(getApplicationContext(),AddCustomerInfoActivity.class);
                        break;
                }
//                if (intent!=null){
//
//                }else {
//                    T.showAnimToast(getApplicationContext(),"拼命开发中，敬请期待！");
//                }
            }
        });
    }
    @Override
    public void showProgress() {

    }
    private void showInfo() {

        AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
        builder.setTitle("温馨提示");
        builder.setMessage("\n" + "您确定要退出应用么？" + "\n");
        builder.setNegativeButton("取消", null);
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                LelaohuirelativesApp.exit();
                System.exit(0);
                finish();
                dialog.cancel();
            }
        });
        builder.show();
    }

    @Override
    protected INetRequestManager getRequestManager() {
        return NetRequestManager.getInstance();
    }

    @Override
    public void hideProgress() {

    }

    @Override
    protected int getlayout() {
        return R.layout.activity_my_info;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void doBasess() {

    }


}
